package optimizers.commons;

import java.io.Serializable;
import java.util.Arrays;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Parameter implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public int optimizeMechanism;
	public double defaultValue;
	public double minValue;
	public double maxValue;
	public double[] values;

	public Parameter(int optimizeMechanism, double defaultValue,
			double minValue, double maxValue, double[] values) {
		this.optimizeMechanism = optimizeMechanism;
		this.defaultValue = defaultValue;
		this.minValue = minValue;
		this.maxValue = maxValue;
		this.values = values;
	}

	public Element getXMLElement(Document doc, String nodeName) {
		Element result = doc.createElement(nodeName);
		result.setAttribute("optimize", String.valueOf(optimizeMechanism));
		result.setAttribute("default", String.valueOf(defaultValue));
		result.setAttribute("min", String.valueOf(minValue));
		result.setAttribute("max", String.valueOf(maxValue));
		result.setAttribute("values", Arrays.toString(values));
		return result;
	}
}
